import type { LabelValueState } from '@/types/global'
import type { TreeNodeData } from './type'
import { http } from '@/utils/http'

const BASE_URL = '/common'

/** @desc 查询字典列表 */
export function listCommonDict<T>(code: string) {
  return http.get<LabelValueState<T>[]>(`${BASE_URL}/dict/${code}`)
}
/** @desc 查询部门树 */
export function listDeptTree(query: { description: string | unknown }) {
  return http.get<TreeNodeData[]>(`${BASE_URL}/tree/dept`, query)
}
/** @desc 查询角色列表 */
export function listRoleDict(query?: { name: string, status: number }) {
  return http.get<LabelValueState<number>[]>(`${BASE_URL}/dict/role`, query)
}
